<script setup lang="ts">
import { storeToRefs } from 'pinia';
import useStore from '../store';

const { todos } = useStore();
const { getNum, type } = storeToRefs(todos);
</script>

<template>
  <footer class="footer">
    <span class="todo-count"
      ><strong>{{ getNum }}</strong> item left</span
    >
    <ul class="filters">
      <li>
        <a
          :class="type === 'All' ? 'selected' : ''"
          href="#/"
          @click="todos.handleChangeType('All')"
          >All</a
        >
      </li>
      <li>
        <a
          :class="type === 'Active' ? 'selected' : ''"
          href="#/active"
          @click="todos.handleChangeType('Active')"
          >Active</a
        >
      </li>
      <li>
        <a
          href="#/completed"
          :class="type === 'Completed' ? 'selected' : ''"
          @click="todos.handleChangeType('Completed')"
          >Completed</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="todos.handleClear">
      Clear completed
    </button>
  </footer>
</template>

<style lang="less" scoped></style>
